version: '[% c("abbrev") %]'
git_url:  https://github.com/hlandau/service.git
git_hash: 0496f910e39ef577ba805f512f6e1b80d652c4b9
filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'

build: '[% c("projects/go/var/build_go_lib") %]'

var:
  container:
    use_container: 1
  go_lib: gopkg.in/hlandau/service.v2
  go_lib_deps:
    - gosvcutils
    - goeasyconfig
  build_go_lib_pre: |
    [% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %]

    tar -C /var/tmp/dist -xf $rootdir/[% c('input_files_by_name/binutils') %]
    export PATH="/var/tmp/dist/binutils/bin:$PATH"

    export CGO_ENABLED=1

    [% IF c("var/linux-cross") %]
      # libcap includes
      mkdir -p /var/tmp/dist/gcc-cross/[% c("var/crosstarget") %]/include/sys/
      cp /usr/include/sys/capability.h /var/tmp/dist/gcc-cross/[% c("var/crosstarget") %]/include/sys/

      # libcap libraries
      cp /lib/[% c("var/crosstarget") %]/libcap.* /var/tmp/dist/gcc-cross/[% c("var/crosstarget") %]/lib/
      cp /usr/lib/[% c("var/crosstarget") %]/libcap.* /var/tmp/dist/gcc-cross/[% c("var/crosstarget") %]/lib/
      cp /lib/[% c("var/crosstarget") %]/libattr.* /var/tmp/dist/gcc-cross/[% c("var/crosstarget") %]/lib/

      # libcap search paths
      export CGO_LDFLAGS="$CGO_LDFLAGS -Wl,-rpath-link=/var/tmp/dist/gcc-cross/[% c("var/crosstarget") %]/lib/"
    [% END %]

targets:
  linux:
    var:
      arch_deps:
        - 'libcap-dev:[% c("var/arch_debian") %]'

input_files:
  - project: container-image
  - name: go
    project: go
  - name: '[% c("var/compiler") %]'
    project: '[% c("var/compiler") %]'
  - name: binutils
    project: binutils
  - name: gosvcutils
    project: gosvcutils
  - name: goeasyconfig
    project: goeasyconfig
